package com.kent.hellokotlin.cClassAndObject

//数据类
private fun foo1() {
    data class User(val name: String, val age: Int) {
        override fun equals(other: Any?): Boolean {
            return super.equals(other)
        }
    }

    val user = User("Kent", 18)
    val copy = user.copy()
    val (name1, age1) = user.copy()
    val (name2, age2) = user

    data class UserName(val name: String) {
        var age: Int = 0
    }

    val user1 = UserName("User")
    val user2 = UserName("User")
    user1.age = 16
    user2.age = 17
    println(user1 == user2)
    println(user1 === user2)

}

private fun foo2() {
    open class User(open var name: String, open var age: Int) {
        override fun equals(other: Any?): Boolean {
            if (other == null || other !is User) {
                return false
            }
            return name == other.name && age == other.age
        }
    }

    data class Kent(val look: String) : User("Kent", 18)

    val kent = Kent("Handsome")
    kent.name = "KentLee"
    kent.age = 18
}

fun main() {
    foo1()
}